<template>
  <el-form class="customer-form">
    <el-row :gutter="8" class="content">
      <el-col :span="12">
        <el-form-item label="创建人:">
          <span>{{ detailData.creator && detailData.creator.userName || '--' }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="申请人:">
          <span>{{ detailData.proposer && detailData.proposer.userName || '--' }}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="8" class="content">
      <el-col :span="12">
        <el-form-item label="创建人部门:">
          <span>{{ detailData.creatorDepartment && detailData.creatorDepartment.value || '--' }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="申请人部门:">
          <span>{{ detailData.department && detailData.department.value || '--' }}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="8" class="content">
      <el-col :span="12">
        <el-form-item label="创建人职位:">
          <span>{{ detailData.creatorPost || '--' }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="申请人职位:">
          <span>{{ detailData.post || '--' }}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="8" class="content">
      <el-col :span="12">
        <el-form-item label="流程编码:">
          <span>{{ detailData.flowCode || '--' }}</span>
        </el-form-item>
      </el-col>
      <el-col v-if="detailData.relatedFlowCode" :span="12">
        <el-form-item label="关联流程:">
          <span class="link" @click="linkToRelated">{{ detailData.relatedFlowCode }}</span>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  props: {
    detailData: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  methods: {
    linkToRelated() {
      const routeUrl = this.$router.resolve({
        name: 'contractDetail',
        params: {
          id: this.detailData.relatedId
        },
        query: {
          processId: this.detailData.relatedProcessId
        }
      });
      window.open(routeUrl.href, '_blank');
    }
  }
};
</script>

<style lang="scss" scoped>
.link {
  color: #406EFF;
  cursor: pointer;
}
.customer-form {
  &::v-deep {
    .el-form-item {
      margin-bottom: 10px;
      .el-form-item__label {
        color: #999;
      }
    }
  }
}
</style>
